<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <title>GYLite</title>
    <meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="full-screen" content="true" />
    <meta name="screen-orientation" content="landscape" />
    <meta name="x5-fullscreen" content="true" />
    <meta name="360-fullscreen" content="true" />
    <style>
        html, body {
            -ms-touch-action: none;
            background: #ffffff;
            padding: 0;
            border: 0;
            margin: 0;
            height: 100%;
        }
        @keyframes loading {
            from {background-position-y:0px;}
            to {background-position-y:-100px;}
        }
        
		
    </style>

    <script>        
        window.pageStart = Date.now();
    </script>	  
</head>

<body style="overflow: hidden">
<div class="loading-bg" id="loading" style="position: fixed;width:100%;height:100%;transform: matrix(1,0,0,1,0,0);">
    <div class="loading-content" id="loading2" style="margin:0 auto;width: 316px;height: 378;background: url(loading/dog.png) no-repeat;animation: loading 0.5s infinite alternate;">
        <div style="position: relative;left:-530px;top:300px;width:1464px;height: 281px;background: url(loading/barBack.png) no-repeat;"></div>
        <div id="id_bar" style="position: relative;left:-530px;top:20px;width: 0px;height: 281px;background: url(loading/bar.png) no-repeat;"></div>
        <div id="id_perTxt" style="width:1464px;text-align: center;color:#ffffff;font-size: 40px;position: relative;top:-140px;left:-570px;">0%</div>
    </div>
</div>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" data-orientation="landscape" data-scale-mode="noScale" data-frame-rate="60"
data-content-width="1920" data-content-height="1080" data-multi-fingered="2" data-show-fps="true" data-show-log="false"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9" draggable="false">
</div>

<script>


    (function(){
        //进度加载UI
        var scl = window.innerWidth / 1920;
        var loading = document.getElementById("loading");
        loading.style.transform = "matrix("+scl+",0,0,"+scl+",0,0)";
        loading.style.paddingTop = (50*scl|0) + "px";        
        window.GlobalLoad = (function(){
            function GlobalLoad(){
                var s = this;
                s.loadDiv2 = document.getElementById("loading2");
		        s.loadDiv = document.getElementById("loading");
                s._globalCurLoadTar = 0;
                s._globalCurLoad = 0;
                s._globalLoadMax = 0;
                s._step = 0;
                s._loadLabel = "";
            }
            GlobalLoad.prototype.addLoadingUI = function()
            {
                var s = this;
                s.loadDiv.appendChild(s.loadDiv2);
			    s.loadDiv.style.zIndex = 0;
            }
            GlobalLoad.prototype.removeLoadingUI = function() 
            {
                var s = this;
                if (s.loadDiv2 && s.loadDiv2.parentNode)
                    s.loadDiv2.parentNode.removeChild(s.loadDiv2);                		
            }           
            GlobalLoad.prototype.globalLoadPercent = function(cur,max,label)
            {
                var s = this;                
                s._globalLoadMax = max;					
                s._loadLabel = label?label:"";
                if(s._globalCurLoadTar < cur)
                    s._globalCurLoadTar = 0;
                if(cur > s.globalLoadMax)
                    cur = s.globalLoadMax;
                else if(cur < 0)
                    cur = 0;                
                if((cur - s._globalCurLoadTar) < 0.01 * max)
                {						
                    s.setPercent(cur,max,label);
                }
                else
                {
                    s._step = (cur - s._globalCurLoadTar) * 0.02;
                    s._globalCurLoadTar = cur;
                    setTimeout(s.loadLoop.bind(s), 16);						
                }
            }
            GlobalLoad.prototype.setPercent = function(cur,max,label){
                var bar;
                var txt;
                var per;         
                var s = this;                       
                s._globalCurLoad = cur;
                bar = document.getElementById("id_bar");
                txt = document.getElementById("id_perTxt");
                if(bar == null || txt == null)return;
                per = max >0?cur / max:0;
                if(per > 1)per = 1;
                if(per < 0)per = 0;                
                txt.innerText = (label?label:"") + (per*100|0) + "%";
                bar.style.width = (1464 * per |0) + "px";  			
            }
            GlobalLoad.prototype.loadLoop = function(){
                var s = this;
                if(s._globalCurLoad >= s._globalLoadMax)
                {
                    s.setPercent(s._globalCurLoadTar, s._globalLoadMax,s._loadLabel);
                    return;
                }
                var val = s._globalCurLoad + s._step;
                if(val > s._globalCurLoadTar)
                {                    
                    s.setPercent(s._globalCurLoadTar, s._globalLoadMax,s._loadLabel);
                    return;
                }                
                s.setPercent(val,s._globalLoadMax,s._loadLabel);
                setTimeout(s.loadLoop.bind(s),0);
            }            
            return GlobalLoad
        })();
        window.globalLoad = new GlobalLoad;        
        
    })(); 

    window["gy_module"] = "game_02";
    window["token"] = "1325735682747924480";
    window["game_version"] = 220127171213;    

    var loadScript = function (list, callback) {
        var loaded = 0;
        var loadNext = function () {            
            loadSingleScript(list[loaded], function () {                
                loaded++;
                globalLoad.globalLoadPercent(loaded,list.length, "加载主程序("+loaded+"/"+list.length+")");
                if (loaded >= list.length) {
                    callback();
                }
                else {
                    loadNext();
                }
            })
        };
        loadNext();
    };

    var loadSingleScript = function (src, callback) {
        var s = document.createElement('script');
        s.async = false;
        s.src = src;		
        s.addEventListener('load', function () {
            s.parentNode.removeChild(s);
            s.removeEventListener('load', arguments.callee, false);
            callback();
        }, false);
        document.body.appendChild(s);
    };

    var xhr = new XMLHttpRequest();
    xhr.open('GET', './manifest.json?v=' + Math.random(), true);
    xhr.addEventListener("load", function () {
        console.log("[" + new Date().toUTCString() + "-" + (Date.now() - window.pageStart) + "]manifest loaded!");
        var manifest = JSON.parse(xhr.response);
        var list = manifest.initial.concat(manifest.game);
        globalLoad.globalLoadPercent(0,list.length, "加载主程序");
        loadScript(list, function () {			
            console.log("[" + new Date().toUTCString() + "-" + (Date.now() - window.pageStart) + "-" + egret.getTimer() + "]egret Inited!");            
            /**
             * {
             * "renderMode":, //Engine rendering mode, "canvas" or "webgl"
             * "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
             * "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
             * "calculateCanvasScaleFactor": //a function return canvas scale factor
             * }
             **/
            egret.runEgret({
                renderMode: "webgl", audioType: 3, antialias: false, calculateCanvasScaleFactor: function (context) {
                    var backingStore = context.backingStorePixelRatio ||
                        context.webkitBackingStorePixelRatio ||
                        context.mozBackingStorePixelRatio ||
                        context.msBackingStorePixelRatio ||
                        context.oBackingStorePixelRatio ||
                        context.backingStorePixelRatio || 1;
                    return (window.devicePixelRatio || 1) / backingStore;
                }
            });
        });
    });
    xhr.send(null);            

</script>
</body>

</html>